import request from '@/utils/request'

// GET     attrInfoList    /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
// DELETE  deleteAttr      /admin/product/deleteAttr/{attrId}
// POST    saveAttrInfo    /admin/product/saveAttrInfo

export interface AttrValueModel {
  id?: number,
  valueName: string,
  attrId?: number,
  // -----------------------
  inputVisible?: boolean // 前端使用,和后端无关,用来控制input的显示和隐藏
}

export interface attrListModel {
  id?: number,
  attrName: string,
  categoryId: number | undefined,
  categoryLevel: number,
  attrValueList: AttrValueModel[]
}

export default {
  getAttrInfoList(category1Id: number, category2Id: number, category3Id: number) {
    return request.get<any, attrListModel[]>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
  },
  saveAttrInfo(attrForm: attrListModel) {
    return request.post<any, null>(`/admin/product/saveAttrInfo`, attrForm)
  },
  deleteAttr(attrId: number) {
    return request.delete<any, null>(`/admin/product/deleteAttr/${attrId}`)
  }
}